import Cookies from 'js-cookie'

import defaultSettings from '@/settings'

const { isFromCenter } = defaultSettings

const TokenKey = isFromCenter ? 'Admin-Token-zyzm' : 'zhuoguan_token'


export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

/** 免密登录密钥 */
export const toKeyKey = '__toKey'

export function setToKey(key) {
  localStorage.setItem(toKeyKey, key)
  return key
}

export function getToKey() {
  return localStorage.getItem(toKeyKey)
}

export function removeToKey() {
  localStorage.removeItem(toKeyKey)
}

export const HardIDKey = Symbol('HardID')

export function getHardID() {
  return window[HardIDKey]
}

export function setHardID(hardID) {
  window[HardIDKey] = hardID
  return window[HardIDKey]
}

export function removeHardID() {
  window[HardIDKey] = undefined
}
